package ltd.followkba.comment.edit;

import static ltd.advskin.MSKIN.MTOAST;

//public class BindUploadActivity extends SkinActivity {
//    private int gTaskIndex;
//    private byte gAppType;
//    private BTaskRun mBTaskRun;
//    private EditText etSelectUserBindUpload;
//    private EditText etSelectSongBindUpload;
//    private EditText etSongIntroBindUpload;
//    private ImageView ivSelectUserBindUpload;
//    private BUserInfo mSelectUserInfo;
//    private BSongInfo mSelectSongInfo;
//    private KcBottomView mKcBottomView;
//    private Timer mTimer;
//    private Thread mThread;
//    private DbsTypeUserID mFavoriteFile;
//    private DbsTypeUserID mSelectSongFile;
//    private int gSelectSong = -1;
//    private TextView tvAudioFileBindUpload;
//    private TextView tvVideoFileBindUpload;
//    private Button btnSaveBindUpload;
//
//    public static void startWithParamete(BTaskRun bTaskRun){
//        MBAPP.mSaveBTaskRun = bTaskRun;
//        MRAM.mActivity.startActivity(new Intent(MRAM.mActivity, BindUploadActivity.class));
//    }
//    @Override
//    protected void onCreate(Bundle savedInstanceState)	{
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_bind_upload);
//        Bundle bundle = this.getIntent().getExtras();       // 新页面 接收数据
//        mBTaskRun = MBAPP.mSaveBTaskRun;
//        MBAPP.mSaveBTaskRun = null;
//        gAppType = mBTaskRun.AppType;
//        mFavoriteFile = new DbsTypeUserID(DbsTypeUserID.USER_FAVORITE, gAppType);
//        initView();
//        showSelecUserSong();
//    }
//    private void initView()	{
//        mKcHeaderView = (KcHeaderView) findViewById(R.id.khvBindUpload);
//        mKcHeaderView.setTitle("绑定帐号自动上传", new KcTypeListener() {
//            @Override
//            public void onMessage(int type){
//                switch (type){
//                    case KcHeaderView.TYPE_CLICK_LEFT:
//                        finish();
//                        break;
//                }
//            }
//        });
//        ivSelectUserBindUpload = (ImageView) findViewById(R.id.ivSelectUserBindUpload);
//        etSelectUserBindUpload = (EditText) findViewById(R.id.etSelectUserBindUpload);
//        etSelectUserBindUpload.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                FavoriteActivity.startWithParamete(gAppType);
//            }
//        });
//        etSelectSongBindUpload = (EditText) findViewById(R.id.etSelectSongBindUpload);
//        etSelectSongBindUpload.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                SongListActivity.startWithParamete(gAppType, mSelectUserInfo.userID, mFavoriteFile);
//            }
//        });
//        etSongIntroBindUpload = (EditText) findViewById(R.id.etSongIntroBindUpload);
//        etSongIntroBindUpload.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//            }
//        });
//        tvAudioFileBindUpload = (TextView) findViewById(R.id.tvAudioFileBindUpload);
//        tvVideoFileBindUpload = (TextView) findViewById(R.id.tvVideoFileBindUpload);
//        btnSaveBindUpload = (Button) findViewById(R.id.btnSaveBindUpload);
//        btnSaveBindUpload.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                new Thread(new Runnable() {
//                    @Override
//                    public void run() {
//                        KgAppBase kgAppBase = MKCS.SwitchBaseApp(gAppType);
//                        if (kgAppBase != null) {
//                            BSongInfo aSongInfo = kgAppBase.GetSongInfo(mSelectSongFile.getMemoryString("itemID"));
//                            if (aSongInfo != null){
//                                MSTRING("aSongInfo A "+aSongInfo.path);
//                                MSTRING("aSongInfo B "+aSongInfo.videoPath);
//                                String gsLocal_1 = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath();
//                                String gsLocal_2 = String.format("%s/%s-%s.mp3", gsLocal_1, aSongInfo.songName, mSelectUserInfo.nickName);
//                                String gsLocal_3 = String.format("%s/%s-%s.mp4", gsLocal_1, aSongInfo.songName, mSelectUserInfo.nickName);
//                                showDownload("正在下载mp3");
//
////                                MSTRING("aaaa "+MUTIL.GET_URL_LENGTH(aSongInfo.AudioUrl));
////
//                                MUTIL.GET_URL_TO_FILE(aSongInfo.path, gsLocal_2);
//                                if (!"".equals(aSongInfo.videoPath)) {
//                                    showDownload("正在下载mp4");
//                                    MUTIL.GET_URL_TO_FILE(aSongInfo.videoPath, gsLocal_3);
//                                }
//                                showDownload("下载");
//                                MTOAST(String.format("下载完成(%s + %s)", mMyUtils.formatFileSize(MAPI.GET_FILE_LENGTH(gsLocal_2)), mMyUtils.formatFileSize(MAPI.GET_FILE_LENGTH(gsLocal_3)) ));
//                            }
//                        }
//
//                    }
//                }).start();
//            }
//        });
//
//
//        mKcBottomView = (KcBottomView) findViewById(R.id.kguBindUpload);
//        mKcBottomView.initView(new KcTypeListener() {
//            @Override
//            public void onMessage(int type){
//                switch (type){
//                    case 1:
//                        uploadFile();
//                        break;
//                    case 2:
//
//                        break;
//                }
//            }
//        });
//        mKcBottomView.setItem(1,-1,"立即上传到" + MUTIL.GET_APP_TYPE_NAME(gAppType));
//    }
//    private void showDownload(final String text){
//        runOnUiThread(new Runnable() {
//            @Override
//            public void run() {
//                btnSaveBindUpload.setText(text);
//                String gsLocal_1 = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath();
//                String gsLocal_2 = String.format("%s/%s-%s.mp3", gsLocal_1, mSelectSongInfo.songName, mSelectUserInfo.nickName);
//                String gsLocal_3 = String.format("%s (%s)", gsLocal_2, MAPI.GET_FILE_LENGTH(gsLocal_2) > 1000 ? "已下载" : "未下载");
//                tvAudioFileBindUpload.setText(gsLocal_3);
//
//                gsLocal_2 = String.format("%s/%s-%s.mp4", gsLocal_1, mSelectSongInfo.songName, mSelectUserInfo.nickName);
//                gsLocal_3 = String.format("%s (%s)", gsLocal_2, MAPI.GET_FILE_LENGTH(gsLocal_2) > 1000 ? "已下载" : "未下载");
//                tvVideoFileBindUpload.setText(gsLocal_3);
//            }
//        });
//    }
//    private void uploadFile(){
//        if (gSelectSong >= 0 && mThread == null) {
//            mKcBottomView.setItem(1,-1,"正在上传");
//            final String intro = etSongIntroBindUpload.getText().toString();
//
//            Runnable runnable = new Runnable() {
//                public void run() {
//                    KgAppBase transBaseApp = MKCS.SwitchBaseApp(0x100 | mBTaskRun.AppType);
//                    if (transBaseApp != null){
//                        mTimer = new Timer();
//                        mTimer.schedule(new TimerTask() {
//                            @Override
//                            public void run() {
//                                runOnUiThread(new Runnable() {
//                                    @Override
//                                    public void run() {
//                                        mKcBottomView.setItem(1,-1,mBTaskRun.UploadResult);
//                                    }
//                                });
//                            }
//                        }, 1, 1000);
//                        transBaseApp.SwitchUser(mBTaskRun.OwnApp.LoginFlag, "", "");
//                        final String gsLocal_1 = transBaseApp.copyMediaFile(1, gSelectSong, mSelectUserInfo, mBTaskRun, intro);
//                        mTimer.cancel();
//                        mThread = null;
//                        if ("ok".equals(gsLocal_1)){
//                            MTOAST("上传成功");
//                            mKcBottomView.postDelayed(new Runnable() {
//                                @Override
//                                public void run() {
//                                    finish();
//                                }
//                            }, 3000);
//                        }else{
//                            runOnUiThread(new Runnable() {
//                                @Override
//                                public void run() {
//                                    mKcBottomView.setItem(1,-1,"上传出错："+gsLocal_1);
//                                }
//                            });
////                            mKcBottomView.setItem(1,-1,"上传出错："+gsLocal_1);
//                        }
//                    }
//                }
//            };
//            mThread = new Thread(runnable);
//            mThread.start();
//        }else{
//            MTOAST("请先选择歌曲");
//        }
//    }
//
//    private void showSelecUserSong(){
//        String selectUserID = mFavoriteFile.getMemoryString("select");
//        MSTRING("showSelecUserSong A "+selectUserID);
//        mSelectUserInfo = (BUserInfo) mFavoriteFile.getItem(selectUserID);
//        MSTRING("showSelecUserSong B "+mSelectUserInfo);
//        if (mSelectUserInfo != null) {
//            String gsLocal_1 = String.format("%s(%s)", mSelectUserInfo.nickName, mSelectUserInfo.userID);
//            MSKIN.showNickName(gsLocal_1, 0, 0, etSelectUserBindUpload);
//            AdvBitmap.setBitmap(C3_FG_NORMAL | CROP_ROUND10, mSelectUserInfo.headFile, R.drawable.c3i_user_head, ivSelectUserBindUpload);
//
//            mSelectSongFile = new DbsTypeUserID(DbsTypeUserID.USER_INFO, gAppType, mSelectUserInfo.userID);
//            gSelectSong = mSelectSongFile.getMemoryInt("select");
//            mSelectSongInfo = (BSongInfo) mSelectSongFile.getItem(mSelectSongFile.getMemoryString("itemID"));
//            MSTRING("mSelectSongInfo A "+gSelectSong+" "+mSelectSongFile.getMemoryString("itemID"));
//            if (mSelectSongInfo != null) {
//                MSTRING("showSelecUser D " + mSelectSongInfo.intro);
//                MSKIN.setText(mSelectSongInfo.songName, etSelectSongBindUpload);
//                MSKIN.setText(mSelectSongInfo.intro, etSongIntroBindUpload);
//                showDownload("下载");
//            }
//        }
//    }
//
//    @Override
//    protected void onDestroy() {
//        if (mTimer!=null) {
//            mTimer.cancel();
//        }
//        super.onDestroy();
//    }
//    @Override
//    protected void onActivityResult(int requestCode, int resultCode, Intent data)	{
//        super.onActivityResult(requestCode, resultCode, data);
//        showSelecUserSong();
//        MSTRING("BindUploadActivity AAAA ");
//    }
//
//}
//
